# ### STAGE 1: Build ###
# # We label our stage as 'builder'
# FROM node:8-alpine as builder

# COPY package.json .

# # Storing node modules on a separate layer will prevent unnecessary npm installs at each build
# RUN apk update \
#     # && apk add --no-cache git \
#     && npm set progress=false \
#     && npm config set depth 0 \
#     && npm cache verify \
#     && npm install --ignore-scripts --unsafe-perm --registry=https://registry.npm.taobao.org \
#     # && npm install --registry=https://registry.npm.taobao.org \
#     # && npm rebuild node-sass \
#     && mkdir /react-app \
#     && cp -R ./node_modules ./react-app

# ## Move to /react-app (eq: cd /react-app)
# WORKDIR /react-app

# # Copy everything from host to /react-app in the container
# COPY . .

# RUN npm run build

### STAGE 2: Setup ###
FROM nginx:1.13.6-alpine

## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/

RUN rm -f /etc/nginx/nginx.conf
COPY nginx/nginx.conf /etc/nginx/

## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*

## From 'builder' stage copy over the artifacts in dist folder to default nginx public folder
COPY dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]
# CMD nginx -g 'daemon off;'